package com.zzxz.practicaltrainingsys.mapper;

import com.zzxz.practicaltrainingsys.entity.Major;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MajorMapper {
    // 查询所有专业
    @Select("select * from major")
    List<Major> getMajor();

    // 根据ID查找
    @Select("select * from major where major_id = #{major_id}")
    Major getMajorById(@Param("major_id") Integer major_id);

    // 新增
    @Insert("insert into major (major_name, college_id) values (#{major_name}, #{college_id})")
    @Options(useGeneratedKeys = true, keyProperty = "major_id")
    int addMajor(Major major);

    //更新
    @Update("update major set major_id=#{major_id},major_name=#{major_name},college_id=#{college_id} where major_id=#{major_id}")
    int updateMajor(Major major);

    //根据学院编号查找专业名称
    @Select("select * from major where college_id = #{college_id}")
    List<Major> getMajorByCollegeId(Integer college_id);

    //测试

}